 /***************************************************************************
 *   Copyright (C) 2010 by ZhangShine , All Rights Reserved                                  
 *   zhangshine0125@gmail.com                                              
 *                                                                         
 *   This program is free software; you can redistribute it and/or modify  
 *   it under the terms of the GNU General Public License as published by  
 *   the Free Software Foundation; either version 2 of the License, or     
 *   (at your option) any later version.                                   
 *                                                                         
 *   This program is distributed in the hope that it will be useful,       
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         
 *   GNU General Public License for more details.                          
 *                                                                         
 *   You should have received a copy of the GNU General Public License     
 *   along with this program; if not, write to the                         
 *   Free Software Foundation, Inc.,                                       
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             
 ***************************************************************************/

#ifndef SINAPARSERXML_H
#define SINAPARSERXML_H

#include <QObject>
#include <QtXml>
#include "account.h"
#include "status.h"
#include "emotion.h"

/*! \class SinaParserXml
 * \brief xml解析
 *
 *
 */
class SinaParserXml : public QObject
{
    Q_OBJECT
public:
    SinaParserXml();
    bool parserSinaAccountInformation(Account *account, QString &xmlContent);
    bool parserStatusXml(QString &content,QList<Status> &statusList, QMap<QString,Status> &retwStatusMap);
    bool parserCommentTimeline(QString &content, QList<Status> &commentList,
                               QMap<QString, Status> &retwCommentMap);
    void parserDirectMessage(QString &xmlContent, QList<Status> &directMessageList);
    void parserDM(QDomElement &messageElement, Status &status);
    bool parserStatus( QDomElement &statusElement , Status &status,Status &retwStatus);
    bool parserCommentStatus( QDomElement &statusElement , Status &status, Status &retwStatus);
    bool parserUserInfo(Status &status, QDomNodeList nodes);
    void parserUnreadXml(QString &xmlContent, int &statusUnread, int &atMeMentionsUnread, 
                         int &commentUnread, int &directMessageUnread, int &newFollower);
    void parserEmotions(QString &xmlContent, QList<Emotion> &emotionList);
    Status parserRetweetedStatus( QDomNodeList nodes);

signals:

public slots:

private:
    void fillAccount(Account *account,QString tagName, QString text);
    void fillStatus(Status &status, QString tagName, QString text);
    void fillUserInfo(Status &status, QString tagName, QString text);
    void fillEmotion(Emotion &emotion, QString tagName, QString text);
    void fillMessage(Status &status, QString tagName, QString text);
    void fillSender(Status &status, QString tagName, QString text);
};

#endif // SINAPARSERXML_H
